﻿using MobiSms.DataModel;
using MobiSms.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MobiSms.ViewModel
{
    public class SampleData:ViewModelBase
    {
        private string sendId1 = string.Format("20130507{0}", DateTime.Now.Ticks);
        private string sendId2= string.Format("20130507{0}", DateTime.Now.AddDays(-20).Ticks);

        private string guid1 = System.Guid.NewGuid().ToString();
        private string guid2 = System.Guid.NewGuid().ToString();

        private DateTime datetime2 = DateTime.Now.AddDays(-20);

        public SampleData()
        {
            
        }

        public void Insert()
        {
            if (Database.CollectionOfSerialNumbers.Count() == 0)
            {
                Database.CollectionOfSerialNumbers.InsertAllOnSubmit(SampleSerial);
            }
            if (Database.CollectionOfReplies.Count() == 0)
            {
                Database.CollectionOfReplies.InsertAllOnSubmit(SampleReply);
            }
            if (Database.CollectionOfMessages.Count() == 0)
            {
                Database.CollectionOfMessages.InsertAllOnSubmit(SampleMessage);
            }
            if (Database.CollectionOfMobiles.Count() == 0)
            {
                Database.CollectionOfMobiles.InsertAllOnSubmit(SampleMobile);
            }
            Submit();
        }

        private IEnumerable<SerialInfo> SampleSerial
        {
            get
            {
                yield return new SerialInfo() { SerialNumber = "ZHR-001-62389465", Password = "123456", ServiceCode = "88888", Signature = "赵榕" };
                yield return new SerialInfo() { SerialNumber = "ZHR-002-90367458", Password = "123456", ServiceCode = "66666", Signature = "WP" };
            }
        }

        private IEnumerable<ReplyInfo> SampleReply
        {
            get
            {
                Random ran = new Random();

                yield return new ReplyInfo()
                {
                    Content = "人是看不清，拍的效果却使很漂亮",
                    Serial = "ZHR-001-62389465",
                    Mobile = "13349236608",
                    Status = ReplyMessageStatusValue.Unread,
                    Time = DateTime.Now.AddTicks(0 - ran.Next()),
                    Extension = "123"
                };
                yield return new ReplyInfo()
                {
                    Content = "我们在不同的年龄里，有着不同的烦恼，你读不懂我的愁，我体会不了你的苦。",
                    Serial = "ZHR-001-62389465",
                    Mobile = "18609636650",
                    Status = ReplyMessageStatusValue.Unread,
                    Time = DateTime.Now.AddDays(0 - ran.Next(2, 100)).AddTicks(ran.Next(int.MaxValue)),
                    Extension = "123"
                };
                yield return new ReplyInfo()
                {
                    Content = "人的一生会有很多次失败，而每一次失败都伴随着阵痛，这种阵痛叫做成长。",
                    Serial = "ZHR-002-90367458",
                    Mobile = "15056485778",
                    Status = ReplyMessageStatusValue.Unread,
                    Time = DateTime.Now.AddDays(0 - ran.Next(2, 100)).AddTicks(ran.Next(int.MaxValue)),
                    Extension = "001"
                };
                yield return new ReplyInfo()
                {
                    Content = "要让微博活下去，首先要让用户活下来。我们可以反向推论一下：微博上，用户不装十三会死么？答案是：十有八九，是会死的，而且，可能死得很难看。",
                    Serial = "ZHR-002-90367458",
                    Mobile = "13907683429",
                    Status = ReplyMessageStatusValue.Unread,
                    Time = DateTime.Now.AddDays(0 - ran.Next(2, 100)).AddTicks(ran.Next(int.MaxValue)),
                    Extension = "001"
                };
                yield return new ReplyInfo()
                {
                    Content = "事实上，过去三年马刺的命运一直很坎坷。2010年季后赛，马刺半决赛0-4被太阳横扫；2011年，他们首轮惨遭灰熊的“黑八奇迹”；2012年，他们在西部决赛2-0的情况下被雷霆逆转……如今，时隔六年重返总决赛的舞台，马刺知道这对他们意味着什么，这一刻他们等待了太久太久。",
                    Serial = "ZHR-002-90367458",
                    Mobile = "13907683429",
                    Status = ReplyMessageStatusValue.Unread,
                    Time = DateTime.Now.AddDays(0 - ran.Next(2, 100)).AddTicks(ran.Next(int.MaxValue)),
                    Extension = "001"
                };
            }
        }

        private IEnumerable<MessageInfo> SampleMessage
        {
            get
            {
                yield return new MessageInfo() { Guid = guid1, Content = "6月6日，是世界爱眼日。记者昨从市妇幼保健院获悉，最近一次视力筛查发现，我市学龄前儿童视力异常率达13%，检查中发现，一名6岁儿童右眼竟近视1200度！", Extension = "123", IsSign = true, SerialNumber = "ZHR-001-62389465", Signature = "赵榕", SubmitTime = DateTime.Now, Time = DateTime.Now, SendId = sendId1, Status = MessageStatus.Succeed };
                yield return new MessageInfo() { Guid = guid2, Content = "The best feeling in the world is knowing someone is missing you. 世界上最好的感觉就是知道有人在想你。", Extension = "001", IsSign = true, SerialNumber = "ZHR-002-90367458", Signature = "WP", SubmitTime = datetime2, Time = datetime2, SendId = sendId2 };
            }
        }

        private IEnumerable<MessageMobileInfo> SampleMobile
        {
            get
            {
                MessageInfo message1 = SampleMessage.ToArray()[0];
                MessageInfo message2 = SampleMessage.ToArray()[1];
                yield return new MessageMobileInfo() { MessageGuid = guid1, SendId = message1.SendId, Mobile = "15056485778" };
                yield return new MessageMobileInfo() { MessageGuid = guid1, SendId = message1.SendId, Mobile = "18668286817" };
                yield return new MessageMobileInfo() { MessageGuid = guid1, SendId = message1.SendId, Mobile = "13605874958" };
                yield return new MessageMobileInfo() { MessageGuid = guid1, SendId = message1.SendId, Mobile = "13349236608" };
                yield return new MessageMobileInfo() { MessageGuid = guid1, SendId = message1.SendId, Mobile = "15865239523" };
                yield return new MessageMobileInfo() { MessageGuid = guid2, SendId = message2.SendId, Mobile = "15056485778" };
                yield return new MessageMobileInfo() { MessageGuid = guid2, SendId = message2.SendId, Mobile = "18668286817" };
                yield return new MessageMobileInfo() { MessageGuid = guid2, SendId = message2.SendId, Mobile = "13605874958" };
                yield return new MessageMobileInfo() { MessageGuid = guid2, SendId = message2.SendId, Mobile = "13349236608" };
                yield return new MessageMobileInfo() { MessageGuid = guid2, SendId = message2.SendId, Mobile = "15865239523" };
            }
        }
    }
}
